import unittest

from aip.employee_demo import employeeDemo
from scropts.test01_login_demo import Test01LoginDemo
from utils import common_assert


class Test03EmployeeDemo(unittest.TestCase):
    # 定义员工id
    employee_id = None
    employee_id = 1391409486387863552

    def setUp(self) -> None:
        self.employee_api_demo = employeeDemo()
        self.login_d = Test01LoginDemo().test01_login_d()

    # 添加员工测试用例
    def test01_add_employee(self):
        self.login_d
        add_employee_data = {
            "username": "test0013",  # 唯一
            "mobile": "15123425692",  # 唯一
            "timeOfEntry": "2020-07-09",
            "formOfEmployment": 1,
            "workNumber": "10012",  # 唯一
            "departmentName": "销售",
            "departmentId": "1266699057968001024",
            "correctionTime": "2020-07-30T16:00:00.000Z"
        }
        response = self.employee_api_demo.add_employee(add_employee_data)
        print(response.json())
        Test03EmployeeDemo.employee_id=response.json().get("data").get("id")
        print(Test03EmployeeDemo.employee_id)
        common_assert(self,response)

    # 修改员工
    def test02_modify_employee(self):
        modify_employee_data = {
            "username": "test01",  # 唯一
        }
        print(Test03EmployeeDemo.employee_id)
        response = self.employee_api_demo.modify_employee(json_data=modify_employee_data, employee_id=Test03EmployeeDemo.employee_id)
        print(response.json())
        common_assert(self, response)

    # 查询
    def test03_get_employee(self):
        self.login_d
        response = self.employee_api_demo.get_employee(Test03EmployeeDemo.employee_id)
        print(response.json())
        common_assert(self, response)

    # 删除员工
    def test04_delete_employee(self):
        response = self.employee_api_demo.delete_employee(Test03EmployeeDemo.employee_id)
        print(response.json())
        common_assert(self, response)
